<div class="row animated" ng-class="{true: 'fadeInRight', false:'fadeInLeft'}[currentAnimated]">
  <div class="col-xs-12 col-md-12">
    <div class="panel panel-default">
      <div class="panel-heading">
        <a ng-click="discard()" href="javascript:;"><i class="backBtn fa fa-arrow-circle-left"></i></a>
        <span class="panelTitle" ng-bind="UserForm.title"></span>
      </div>
      <div class="panel-body">
        <form novalidate role="form" name="userForm" class="form-horizontal">
          <div class="form-group" ng-class="{'has-error': userForm.userName.$invalid && userForm.userName.$dirty}">
            <label class="col-xs-3 col-md-2 control-label">用户名：</label>
            <div class="col-xs-7 col-md-8">
              <input type="text" name="userName" class="form-control w25c" placeholder="用户名" ng-model="user.userName" ng-maxlength="25" ng-pattern="/^[A-Za-z0-9_-]*$/">
            </div>
            <div class="col-xs-2 col-md-2" ng-show="userForm.userName.$dirty && userForm.userName.$invalid">
              <span class="text-danger" ng-show="userForm.userName.$error.minlength || userForm.userName.$error.maxlength">用户名必须是3-20位字符</span>
              <span class="text-danger" ng-show="userForm.userName.$error.pattern">用户名只能是大小写字母和数字组成</span>
            </div>
          </div>
          <div class="form-group" ng-class="{'has-error': userForm.nickName.$invalid && userForm.nickName.$dirty}" ng-if="!user.openid">
            <label class="col-xs-3 col-md-2 control-label">昵称：</label>
            <div class="col-xs-7 col-md-8">
              <input type="text" name="nickName" class="form-control w25c" placeholder="昵称" ng-model="user.nickName" required>
            </div>
            <div class="col-xs-2 col-md-2" ng-show="userForm.nickName.$dirty && userForm.nickName.$invalid">
              <span class="text-danger" ng-show="userForm.nickName.$error.required">请输入昵称</span>
            </div>
          </div>
          <div class="form-group" ng-class="{'has-error': userForm.password.$invalid && userForm.password.$dirty}">
            <label class="col-xs-3 col-md-2 control-label">用户密码：</label>
            <div class="col-xs-7 col-md-8">
              <input type="password" name="password" id="password" class="form-control w25c" placeholder="用户密码" ng-model="user.password">
            </div>
            <div class="col-xs-2 col-md-2" ng-show="userForm.password.$dirty && userForm.password.$invalid">
              <span class="text-danger" ng-show="userForm.password.$error.required">用户密码不能为空</span>
            </div>
          </div>
          <div class="form-group" ng-class="{'has-error': userForm.repassword.$invalid && userForm.repassword.$dirty}">
            <label class="col-xs-3 col-md-2 control-label">确认密码：</label>
            <div class="col-xs-7 col-md-8">
              <input type="password" name="repassword" pw-check="password" class="form-control w25c" placeholder="确认密码" ng-model="user.repassword">
            </div>
            <div class="col-xs-2 col-md-2" ng-show="userForm.repassword.$dirty && userForm.repassword.$invalid">
              <span class="text-danger" ng-show="userForm.repassword.$error.pwmatch">两次输入密码不一致</span>
            </div>
          </div>
          <div class="form-group" ng-class="{'has-error': userForm.sex.$invalid && userForm.sex.$dirty}">
            <label class="col-xs-3 col-md-2 control-label">性别：</label>
            <div class="col-xs-7 col-md-8">
              <input icheck type="radio" name="sex" value="1" ng-model="user.gender" ng-disabled="true">&nbsp;男&nbsp;&nbsp;
              <input icheck type="radio" name="sex" value="2" ng-model="user.gender" ng-disabled="true">&nbsp;女
            </div>
          </div>
          <div class="form-group" ng-class="{'has-error': userForm.model.$invalid && userForm.model.$dirty}">
            <label class="col-xs-3 col-md-2 control-label">用户类型：</label>
            <div class="col-xs-7 col-md-8">
              <select name="model" class="form-control w25c" ng-model="user.model" required>
                <option value="">----请选择----</option>
                <option ng-repeat="item in user.typeList" value="{{item.value}}">{{item.text}}</option>
              </select>
            </div>
            <div class="col-xs-2 col-md-2" ng-show="userForm.type.$dirty && userForm.type.$invalid">
              <span class="text-danger" ng-show="userForm.type.$error.required">请用户类型</span>
            </div>
          </div>
          <div class="form-group" ng-class="{'has-error': userForm.agentSpreadLevel.$invalid && userForm.agentSpreadLevel.$dirty}" ng-if="user.model == 2">
            <label class="col-xs-3 col-md-2 control-label">传播级别：</label>
            <div class="col-xs-7 col-md-8">
              <select name="agentSpreadLevel" class="form-control w25c" ng-model="user.agentSpreadLevel">
                <option value="">----请选择----</option>
                <option ng-repeat="item in user.agentSpreadLevels" value="{{item.propertyName}}">{{item.desc}}</option>
              </select>
            </div>
            <div class="col-xs-2 col-md-2" ng-show="userForm.agentSpreadLevel.$dirty && userForm.agentSpreadLevel.$invalid">
              <span class="text-danger" ng-show="userForm.agentSpreadLevel.$error.required">请传播级别</span>
            </div>
          </div>
          <div class="form-group" ng-class="{'has-error': userForm.spreadLevel.$invalid && userForm.spreadLevel.$dirty}" ng-if="user.model == 1 || user.model == 0">
            <label class="col-xs-3 col-md-2 control-label">传播级别：</label>
            <div class="col-xs-7 col-md-8">
              <select name="spreadLevel" class="form-control w25c" ng-model="user.agentSpreadLevel">
                <option value="">----请选择----</option>
                <option ng-repeat="item in user.spreadLevels" value="{{item.propertyName}}">{{item.desc}}</option>
              </select>
            </div>
            <div class="col-xs-2 col-md-2" ng-show="userForm.spreadLevel.$dirty && userForm.spreadLevel.$invalid">
              <span class="text-danger" ng-show="userForm.spreadLevel.$error.required">请传播级别</span>
            </div>
          </div>
          <div class="form-group" ng-class="{'has-error': userForm.rid.$invalid && userForm.rid.$dirty}">
            <label class="col-xs-3 col-md-2 control-label">推荐人：</label>
            <div class="col-xs-7 col-md-8">
              <input type="number" name="rid" class="form-control w25c" ng-model="user.rid" />
            </div>
          </div>
          <div class="form-group" ng-class="{'has-error': userForm.mobileNumber.$invalid && userForm.mobileNumber.$dirty}">
            <label class="col-xs-3 col-md-2 control-label">手机号码：</label>
            <div class="col-xs-7 col-md-8">
              <input type="text" name="mobileNumber" class="form-control w25c" placeholder="手机号码" ng-model="user.mobileNumber" required ng-pattern="/^[0-9]{11}$/">
            </div>                  
            <div class="col-xs-2 col-md-2" ng-show="userForm.mobileNumber.$dirty && userForm.mobileNumber.$invalid">
              <span class="text-danger" ng-show="userForm.mobileNumber.$error.pattern">无效的手机号码</span>
            </div>        
          </div>
          <div class="form-group" ng-class="{'has-error': userForm.bornDate.$invalid && userForm.bornDate.$dirty}">
            <label class="col-xs-3 col-md-2 control-label">出生年月：</label>
            <div class="col-xs-7 col-md-8">
              <input type="text" name="bornDate" id="bornDate" idate class="form-control w25c" placeholder="出生年月" ng-model="user.bornDate">              
            </div>                    
            <div class="col-xs-2 col-md-2" ng-show="userForm.bornDate.$dirty && userForm.birthday.$invalid">
              <span class="text-danger" ng-show="userForm.bornDate.$error.required">请录入出生年月</span>
            </div>
          </div>
          <div class="form-group" ng-class="{'has-error': userForm.emailAddress.$invalid && userForm.emailAddress.$dirty}">
            <label class="col-xs-3 col-md-2 control-label">电子邮箱：</label>
            <div class="col-xs-7 col-md-8">
              <input type="email" name="emailAddress" class="form-control w25c" placeholder="电子邮箱" ng-model="user.emailAddress"  ng-minlength="5">
            </div>                     
            <div class="col-xs-2 col-md-2" ng-show="userForm.emailAddress.$dirty && userForm.emailAddress.$invalid">
              <span class="text-danger" ng-show="userForm.emailAddress.$error.required">请录入电子邮箱</span>
              <span class="text-danger" ng-show="userForm.emailAddress.$error.email">无效的电子邮箱</span>
              <span class="text-danger" ng-show="userForm.emailAddress.$error.minlength">无效的电子邮箱</span>
            </div>   
          </div>
          <div class="form-group">
            <label class="col-xs-3 col-md-2 control-label">用户头像：</label>
            <div class="col-xs-7 col-md-8">
              <a ng-if="user.icon" href="javascript:void(0)" class="fl whiteblock" ngf-select="upload($file)" ngf-pattern="'image/*'" ngf-accept="'image/*'" ngf-max-size="10MB">
                <img ng-src="{{user.icon}}" width="80" border="0">
              </a>
              <div class="button btn btn-primary fl" ngf-select="upload($file)" ngf-pattern="'image/*'" ngf-accept="'image/*'" ngf-max-size="10MB">上传头像</div>
              <input type="text" readonly class="form-control" name="icon" ng-model="user.icon" style="display:none;">
            </div>       
          </div>
          <div class="col-xs-offset-2 col-md-offset-2 col-xs-offset-10 col-md-offset-10">
            <button class="btn btn-primary" type="submit" ng-click="submitForm()"  ng-disabled="userForm.$invalid">保存</button>
            <button class="btn btn-white" ng-click="discard()">取消</button>
          </div>
        </form>
      </div>
    </div>    
  </div>
</div>